<!-- Page statistics and control buttons area -->
    <div class="statsRow">
        <div class="wrapper statsItems">
			
            <!-- Stats item -->
            <div class="sItem ticketsStats">
                <h2><a title="" class="value"><?php echo $this->countCampaigns['count_campaigns']; ?><span>Campaigns</span></a></h2>
                <div class="statsDetailed" id="s1">
                    <div class="statsContent">
                        <div class="sElements">
                            <div class="sDisplay"><h4><?php echo $this->countActiveCampaigns['count']; ?></h4><span>active</span></div>
                            <div class="sDisplay"><h4><?php echo $this->countNotConfirmedCampaigns['count']; ?></h4><span>stopped</span></div>
                            <div class="sDisplay"><h4><?php echo $this->countBlockedCampaigns['count']; ?></h4><span>blocked</span></div>
                        </div>
                        <span class="line"></span>
                        <div class="statsUpdate">
                            <span>Next update in:</span>
                            <span>19 hrs 49 min</span>
                            <div class="contentProgress"><div class="barG tipS" title="19%" id="bar1"></div></div>
                        </div>
                        <div class="statsDropBtn"><a href="#" class="button basic"><img src="/images/icons/dark/stats.png" class="icon" alt="" /><span>View statistics</span></a></div>
                    </div>
                </div>
                <span class="changes">
                    <span class="negBar" values="5,10,15,20,18,16,14,20,15,16"></span>
                    <span class="negative">+0.6%</span>
                </span>
            </div>
			
			<div class="sItem ticketsStats">
                <h2><a title="" class="value"><?php echo $this->countAdvertisements['count']; ?><span>Advertisements</span></a></h2>
                <div class="statsDetailed" id="s1" style="width:300px">
                    <div class="statsContent">
                        <div class="sElements">
                            <div class="sDisplay"><h4><?php echo $this->countContextAdvertisements; ?></h4><span>context</span></div>
                            <div class="sDisplay"><h4><?php echo $this->countBannerAdvertisements['count']; ?></h4><span>banners</span></div>
                            <div class="sDisplay"><h4><?php echo $this->countBlogAdvertisements['count']; ?></h4><span>microblogs</span></div>
		            <div class="sDisplay"><h4><?php echo $this->countSocialAdvertisements['count']; ?></h4><span>social</span></div>
                        </div>
                        <span class="line"></span>
                        <div class="statsUpdate">
                            <span>Next update in:</span>
                            <span>19 hrs 49 min</span>
                            <div class="contentProgress"><div class="barG tipS" title="19%" id="bar1"></div></div>
                        </div>
                        <div class="statsDropBtn"><a href="#" class="button basic"><img src="/images/icons/dark/stats.png" class="icon" alt="" /><span>View statistics</span></a></div>
                    </div>
                </div>
                <span class="changes">
                    <span class="negBar" values="5,10,15,20,18,16,14,20,15,16"></span>
                    <span class="negative">+0.6%</span>
                </span>
            </div>
			
			<!-- Stats item -->
            <div class="sItem usersStats">
                <h2><a title="" class="value"><?php echo $this->allPayments['payments'].'$'; ?><span>Advertiser's payments</span></a></h2>
                <div class="statsDetailed" id="s3">
                    <div class="statsContent">
                        <div class="sElements">
                            <div class="sDisplay"><h4><?php echo $this->lastMonthPayments['payments'].'$'; ?></h4><span>last month</span></div>
                            <div class="sDisplay"><h4><?php echo $this->reservedForCampaigns['reserved_budget'].'$'; ?></h4><span>reserved for campaigns</span></div>
                            <div class="sDisplay"><h4><?php echo $this->todayPayments['payments'].'$'; ?></h4><span>payed today</span></div>
                        </div>
                        <span class="line"></span>
                        <div class="statsUpdate">
                            <span>Next update in:</span>
                            <span>10 hrs 55 min</span>
                            <div class="contentProgress"><div class="barG tipS" id="bar3" title="32%"></div></div>
                        </div>
                        <div class="statsDropBtn"><a href="#" class="button basic"><img src="/images/icons/dark/users.png" class="icon" alt="" /><span>View advertisers</span></a></div>
                    </div>
                </div>
                <span class="changes">
                    <span class="zeroBar" values="5,10,15,20,25,30,35,40,45,50"></span>
                    <span class="zero">0.0%</span>
                </span>
            </div>
			
        </div>
    </div>
	<div class="line"></div>

    <!-- Main content wrapper -->
    <div class="wrapper">
    
        <!-- Dynamic table -->
        <div class="widget">
            <div class="title"><img src="/images/icons/dark/full2.png" alt="" class="titleIcon" /><h6>Dynamic table</h6></div>
            <table cellpadding="0" cellspacing="0" border="0" class="display dTable">
            <thead>
            <tr>
            <th>Название</th>
            <th>Владелец</th>
            <th>Количество рекламы</th>
            <th>Мини сайт</th>
			<th>Дата начала</th>
            <th>Дата окончания</th>
			<th>Тематика</th>
			<th>Бюджет</th>
			<th>Затраты</th>
            <th>Статус</th>
            <th>Действия</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($this->allCampaigns as $val) { ?>    
                <?php 
                if ($val['id_status'] == 1) {
                    echo '<tr class="gradeA">';
                }
                if ($val['id_status'] == 2) {
                    echo '<tr class="gradeC">';
                }
                if ($val['id_status'] == 3) {
                    echo '<tr class="gradeX">';
                }
                ?>
                <td><?php echo $val['name']; ?></td>
                <td><?php echo $val['login']; ?></td>
                <td></td>            
                <td class="center"></td>
                <td class="center"><?php echo date('d-m-Y', strtotime($val['date_start'])); ?></td>
                    <td class="center"><?php echo date('d-m-Y', strtotime($val['date_end'])); ?></td>
                    <td class="center"><?php echo $val['category']; ?></td>
                    <td class="center"><?php echo $val['start'].'$'; ?></td>
                    <td class="center"><?php echo $val['costs'].'$'; ?></td>
                    <td class="center"><?php echo $val['status']; ?></td>
                    <td class="center">
                        email 
                        <?php
                        if ($val['status'] === 'active') {
                            echo '<a href="'.$this->url(array(
                                'module'     => 'back',
                                'controller' => 'campaigns',
                                'action'     => 'changestatus',
                                'id'         => $val['id'],
                                'status'     => 3
                            )).'">block&nbsp;</a>';
                        } elseif ($val['id_status'] == 'not confirmed') {
                            echo '<a href="'.$this->url(array(
                                'module'     => 'back',
                                'controller' => 'campaigns',
                                'action'     => 'changestatus',
                                'id'         => $val['id'],
                                'status'     => 1
                            )).'">confirm&nbsp;</a>';
                        } else {
                            echo '<a href="'.$this->url(array(
                                'module'     => 'back',
                                'controller' => 'campaigns',
                                'action'     => 'changestatus',
                                'id'         => $val['id'],
                                'status'     => 1
                            )).'">activation&nbsp;</a>';
                        }
                        
                        echo '<a href="'.$this->url(array(
                            'module'     => 'back',
                            'controller' => 'campaigns',
                            'action'     => 'deletecampaign',
                            'id'         => $val['id']
                        )).'">delete</a>'; 
                        ?>
                    </td>
                </tr>
            <?php } ?>
            </tbody>
            </table>  
        </div>
    </div>